import time

from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By

driver=webdriver.Edge()
driver.maximize_window()
driver.get('https://www.jiuxian.com/')
time.sleep(2)
# 登录
driver.find_element(By.CLASS_NAME,'headerLogin').click()
time.sleep(2)
driver.find_element(By.ID,'userName').send_keys('18986670716')
time.sleep(2)
driver.find_element(By.ID,'password').send_keys('Aa123456')
time.sleep(15)

driver.find_element(By.NAME,'bi_Usuallogin').click()
time.sleep(2)

driver.find_element(By.CLASS_NAME,'bindSub').click()
time.sleep(2)
# 搜索
search=driver.find_element(By.XPATH,'//input[@id="wd" or @class="search-from"]')
search.send_keys('茅台')
time.sleep(2)
search.send_keys(Keys.ENTER)
time.sleep(3)
# 点击图片。跳转商品详情页面
driver.find_element(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img').click()
time.sleep(2)
# 多窗口切换
driver.switch_to.window(driver.window_handles[-1])


